﻿using UnityEngine;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Blo
{
    public class TableWorldSeedBlo
    {
        public static TableWorldSeed GetWorldSeedById(string id)
        {
            return Dict.DictDataManager.Instance.tableWorldSeedDao.GetById(id);
        }

        public static List<TableWorldSeed> GetWorldSeedData(int level)
        {
            List<TableWorldSeed> res = new List<TableWorldSeed>();
            var list = Dict.DictDataManager.Instance.tableWorldSeedDao.CacheList;
            for( int i = 0; i < list.Count && i < level;++i)
            {
                res.Add(list[i]);
            }
            return res;
        }

        public static List<TableWorldSeed> GetDataByGroup(string groupId)
        {
            return Dict.DictDataManager.Instance.tableWorldSeedDao.GetByOneIndex(groupId);
        }

        public static TableWorldSeed GetNextRoleLevelup(int currentId)
        {
            List<TableWorldSeed> willRes = new List<TableWorldSeed>();

            var list = Dict.DictDataManager.Instance.tableWorldSeedDao.CacheList;
            foreach(var seed in list)
            {
                if(seed.type == 3)
                {
                    willRes.Add(seed);
                }
            }

            willRes.Sort((lh, rh) => { return int.Parse(lh.id) - int.Parse(rh.id); });

            foreach (var seed in willRes)
            {
                if(currentId < int.Parse(seed.id ))
                {
                    return seed;
                }
            }

            return willRes[willRes.Count-1];
        }
    }
}